Loading
Scriptbox
 VBScript Links 
 About VBscript 
 JavaScript Links 
 About JavaScript 
 Powershell Links 
 PSCRIPT the Script Launcher 
 PowerShell Shortcut Keys 
 About Powershell 
     VBScript
    JavaScript
    Powershell
Disclaimer
Contact
Latest 10 Scripts
Script search
  :: { Category } :: 0-9ABCDEFGHIJKLMNOPQRSTUVWXYZ
         

Search Options:  Stop  a  Service  

 Content of Stop a Service.vbs
MD5 Hash: 07AE83D60D235E6E1DEB3EE382DDD1A6

Msgbox StartService("Alerter")

' --------------------------------------- - Stop a Service -
Private Function StopService(strService)

On Error Resume Next

Dim oWshShell : Set oWshShell = CreateObject("WScript.Shell")

Dim oService, iTimeOut, strComputername, tt
strComputername = oWshShell.ExpandEnvironmentStrings("%COMPUTERNAME%")
iTimeOut = 60

Set oService = GetObject("WinNT://" & strComputername & "/" & strService)

If (Not oService.status = 1) Then
oService.Stop
wscript.sleep(250)

For tt = 0 to iTimeOut
If (oService.status = 1) Then
Exit For
Else
wscript.sleep(1000)
End If
Next
End if

If (IsObject(oService)) Then Set oService = Nothing
If (IsObject(oWshShell)) Then Set oWshShell = Nothing

If ( Err.Number <> 0 ) Then
StopService = "ERROR: " & Err.Number & " " & Err.Description
Err.Clear
Else
StopService = strService & " stopped successful"
End If

End Function

   © 2008 - 2013 Boris Toll      :: Scripts available: 6.481 ::      :: scriptbox.toll.at ::      :: powered by www.toll.at ::
  Google Entries:n/a
  Yahoo Backlinks:n/a
  Live Backlinks:n/a
  del.icio.us Bookmarks:n/a
  Technorati Links:n/a